<template>
  <el-button :disabled="isdisab" @click="ck">{{ ztext }}</el-button>
</template>
  
  <script >
import { defineComponent, ref } from "vue";

export default defineComponent({
  props: {
    text: {
      type: String,
      default: "点击发送验证码",
    },
  },
  setup(props) {
    const isdisab = ref(false);
    let { text } = { ...props };
    const tmnb = ref(5);
    const ztext = ref(text);
    const ck = () => {
      isdisab.value = !isdisab.value;
      ztext.value = tmnb.value;
      let tm = setInterval(() => {
        if (ztext.value === 0) {
          console.log("⏲️来到了这");
          clearInterval(tm);
          isdisab.value = !isdisab.value;
          ztext.value = text;
        } else {
          --ztext.value;
        }
      }, 1000);
    };
    return { ck, isdisab, tmnb, ztext };
  },
});
</script>
  
  <style scoped lang="less" >
</style>
  